package Day05;

import java.util.Arrays;

public class Text3 {
    //调整数组顺序使得奇数位于偶数之前。调整之后，不关心大小顺序。
    //如数组：[1,2,3,4,5,6]
    //调整后可能是：[1, 5, 3, 4, 2, 6]
    public static void main(String[] args) {
        int[] a = {1,2,3,4,5,66};
        find(a);
        System.out.println(Arrays.toString(a));
    }

    public static void  find(int[] a){
        int left = 0;
        int right = a.length -1;
        while(left < right){
            while(left < right && a[left] % 2 != 0){
                left++;
            }
            while(left < right && a[right] % 2 == 0){
                right--;
            }
            int temp = a[left];
            a[left] = a[right];
            a[right] = temp;
        }
    }
}
